package chapter04;

/**
 * ClassName: Exercise05
 * Package: chapter04
 * Description:
 *
 * @Author fjorid
 * @Create 2025/2/19 20:55
 * @Version 1.0
 */
public class Exercise06 {
    public static void main(String[] args) {

        int[] array = new int[10];

        // 对数组进行赋值，使每个元素的值等于其下标
        for (int i = 0; i < array.length; i++) {
            array[i] = i;
        }


        System.out.print("原始数组: ");
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
        System.out.println();

        // 将数组倒置
        int left = 0;
        int right = array.length - 1;
        while (left < right) {

            int temp = array[left];
            array[left] = array[right];
            array[right] = temp;
            left++;
            right--;
        }


        System.out.print("倒置后的数组: ");
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
    }
}


